// pages/myself/info.js
// pages/myself/myself.js
var util = require('../../utils/util.js');
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        listInfo: [],
        showTopTips: false,
        fansinfo:[],
        errorMsg: ""
    },
    onLoad: function (options) {
        this.setData({
            userInfo: app.globalData.userInfo
        });
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onShow: function (options) {
        var that = this;
        this.setData({
          listInfo: app.globalData.listInfo
        })
        this.getfansinfo();
    },
    getfansinfo:function(){
        var that = this;

        wx.request({
            url: app.globalData.hostUrl + 'member/getfansinfo',
            data: {
                id: wx.getStorageSync('userId')
            },
            success: function (res) {
               // console.log(res);
                that.setData({
                    fansinfo:res.data.result
                })
            }
        })
    },
    formSubmit: function (e) {
        var that = this;
        var postdata = {
          phone: e.detail.value.phone,
          realname: e.detail.value.realname,
          bankno: e.detail.value.bankno,
          bankaddr: e.detail.value.bankaddr,
          id: wx.getStorageSync('userId')
        };
     // console.log(postdata);
        wx.request({
            url: app.globalData.hostUrl + 'member/modifyfansinfo',
            data: postdata,
            header: {
              'Content-Type': 'application/x-www-form-urlencoded',
              'grant-appid': app.globalData.appid
            },
            method: 'POST',
            success: function (res) {
//                console.log(res);
                if (res.data.code == 200) {
                    wx.showToast({
                        title: '修改成功',
                        icon: 'success',
                        duration: 2000
                    })
                }
                else {
                    wx.showToast({
                        title: '修改失败',
                        icon: 'error',
                        duration: 2000
                    })
                }
            }
        })
    },
  gohome: function () {
    wx.redirectTo({
      url: '../index/index',
    })
  },
  yuy: function () {
    if (1 == wx.getStorageSync('roleidentity')) {
      wx.redirectTo({
        url: '../myself/thappointment',
      })
    }
    else {
      wx.redirectTo({
        url: '../myself/myappointment',
      })
    }
  },
  orders: function () {
    if (1 == wx.getStorageSync('roleidentity')) {
      wx.redirectTo({
        url: '../myself/trorder',
      })
    }
    else {
      wx.redirectTo({
        url: '../myself/myorder',
      })
    }
  },
  mys: function () {
    wx.redirectTo({
      url: '../myself/myself',
    })
  },
})